package com.rabbitmq.springbootrabbitmq.consumer;

import com.rabbitmq.springbootrabbitmq.config.ConfirmConfig;
import com.rabbitmq.springbootrabbitmq.config.DelayedQueueConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Date;

//消费基于插件的延迟消息
@Slf4j
@Component
public class ConfirmQueueConsumer {

    //监听消息
    @RabbitListener(queues = ConfirmConfig.CONFIRM_QUEUE_NAME)
    public void receiveDelayQueue(Message message){
        String msg = new String(message.getBody());
        log.info("当前时间：{}，收到确认的消息为：{}",new Date().toString(),msg);
    }

    @RabbitListener(queues = ConfirmConfig.WARNING_QUEUE_NAME)
    public void receiveWarningQueue(Message message){
        String msg = new String(message.getBody());
        log.info("路由报警！！！收到报警消息为：{}",msg);
    }
}
